package whf.framework.report.export.view;

import java.util.List;

import whf.framework.datasource.DataRow;
import whf.framework.datasource.DataSource;
import whf.framework.meta.entity.IMeta;
import whf.framework.report.export.ReportBuilder;
import whf.framework.util.Utils;
import whf.framework.web.tag.TableColumn;
import whf.framework.web.tag.TableModel;
import whf.framework.web.tag.ext.IColumn;

/**
 * @author wanghaifeng
 *
 */
public abstract class AbstractView implements View {
	protected ReportBuilder model;

	protected TableModel tableModel;

	protected List<IColumn> columns = Utils.newArrayList();

	protected DataSource<DataRow> dataSource;

	public AbstractView(ReportBuilder model, TableModel tableModel) {
		this.model = model;
		this.tableModel = tableModel;
		List<TableColumn> cols = this.tableModel.getColumns();
		for(TableColumn col: cols){
			if(col.isVisible()){
				this.columns.add(col);
			}
		}
		this.dataSource = tableModel.getDataSource();
	}
	
	public final String getHeaderTitle(){
		IMeta meta = this.tableModel.getMeta();
		if(meta != null){
			return meta.getName();
		} else {
			return null;
		}
	}
}
